import javax.microedition.lcdui.*;



class FlashMessage implements Runnable {
	private Othello othello;
	public Image image;
	public int counter;
	private Thread thread;

	public FlashMessage(Othello o) {
		othello = o;
		image = null;
		counter = 0;
		thread = null;
	}

	public void setMessage(Image i,int c) {
		image = i;
		counter = c*2;
		start();
	}

	public boolean showMessage() { return counter>0 && (counter&1)==0; }

	public void start() {
		if(thread!=null) return;
		othello.lock();
		thread = new Thread(this);
		thread.start();
	}

	public void stop() {
		image = null;
		counter = 0;
		thread = null;
		othello.repaint();
		othello.unlock();
	}

	public void run() {
		for(; thread!=null && counter>1; counter--) {
			othello.repaint();
			try { Thread.sleep(500); } catch(Exception ex) {}
		}
		stop();
	}
}


